﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.world {
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class UpdateBabyTreatmentCommand extends Command {

        public var event:UpdateTreatmentEvent;
        public var inventoryModel:InventoryModel;

        override public function execute():void{
            var _local2:String;
            var _local1:ITreatable = this.event.patient;
            if (_local1.currentTreatment){
                this.event.params.id = _local1.currentTreatment.id;
                this.dispatchTreatmentRequest();
                if (this.event.params.item_type){
                    _local2 = this.event.params.item_type;
                    this.inventoryModel.decreaseNumberOfItemsByOne(_local2);
                };
            };
        }
        private function dispatchTreatmentRequest():void{
            var _local1:RequestEvent = new RequestEvent(EventConstants.SEND_REQUEST, this.onResult);
            _local1.addRequest(this.event.command, this.event.params);
            dispatch(_local1);
        }
        private function onResult(_arg1:ResultVO):void{
            var _local2:Function;
            if (_arg1.success){
                _local2 = this.event.callback;
                _local2(_arg1);
            };
        }

    }
}//package net.wooga.pets.controllers.world 
